<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="text"></div>
    <script>
      const oText = document.querySelector(".text");
      function show(text) {
        const str = `<div>${new Date()}:${text}</div>`;
        oText.innerHTML += str;
      }
      function connect() {
        const ws = new WebSocket("ws://localhost:10050/autoSchedule");
        ws.onopen = () => {
          ws.send("hello world");
          show("已连接");
        };
        ws.onmessage = (e) => {
          const res = e.data;
          show(res);
        };
      }
      connect();
    </script>
  </body>
</html>
